<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Python," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="Python 的变量&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;变量是计算机内存中的一块区域，变量可以存储规定范围内的值，而且值可以改变。&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;python下变量是对一个数据的引用。 变量的命名： 变量名由字母、数字、下划线组成。 变量不能以数字开头 不可以">
<meta name="keywords" content="Python">
<meta property="og:type" content="article">
<meta property="og:title" content="Python 的变量">
<meta property="og:url" content="https://hcldirgit.github.io/2017/08/10/Python/1. Python 基础篇/1. Python 基础语法/1.4 Python 的变量/5. Python 的变量/index.html">
<meta property="og:site_name" content="失落的乐章">
<meta property="og:description" content="Python 的变量&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;变量是计算机内存中的一块区域，变量可以存储规定范围内的值，而且值可以改变。&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;python下变量是对一个数据的引用。 变量的命名： 变量名由字母、数字、下划线组成。 变量不能以数字开头 不可以">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-06-19T13:38:29.665Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Python 的变量">
<meta name="twitter:description" content="Python 的变量&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;变量是计算机内存中的一块区域，变量可以存储规定范围内的值，而且值可以改变。&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;python下变量是对一个数据的引用。 变量的命名： 变量名由字母、数字、下划线组成。 变量不能以数字开头 不可以">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hcldirgit.github.io/2017/08/10/Python/1. Python 基础篇/1. Python 基础语法/1.4 Python 的变量/5. Python 的变量/"/>





  <title>Python 的变量 | 失落的乐章</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>











  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">失落的乐章</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术面前，永远都是学生。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://hcldirgit.github.io/2017/08/10/Python/1. Python 基础篇/1. Python 基础语法/1.4 Python 的变量/5. Python 的变量/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="失落的乐章">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/0.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="失落的乐章">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Python 的变量</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-08-10T14:00:36+08:00">
                2017-08-10
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="Python-的变量"><a href="#Python-的变量" class="headerlink" title="Python 的变量"></a>Python 的变量</h1><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;变量是计算机内存中的一块区域，变量可以存储规定范围内的值，而且值可以改变。<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;python下变量是对一个数据的引用。</p>
<h2 id="变量的命名："><a href="#变量的命名：" class="headerlink" title="变量的命名："></a>变量的命名：</h2><ol>
<li>变量名由字母、数字、下划线组成。</li>
<li>变量不能以数字开头</li>
<li>不可以使用关键字</li>
<li>a a1 _a，这些都是合法的变量名<br> 表达式是将不同的数据（包括变量、函数）用运算符号按一定规则连接起来的一种式子。</li>
</ol>
<h3 id="Python对象的三要素：id、type、value"><a href="#Python对象的三要素：id、type、value" class="headerlink" title="Python对象的三要素：id、type、value"></a>Python对象的三要素：id、type、value</h3><ul>
<li>id：是对象的唯一标识，是对象在内存中的存储地址</li>
<li>type：是对象的数据类型</li>
<li>value：是对象的值，是对象在内存中存放的数据</li>
</ul>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;还有一个name，理解为变量名</p>
<p>###变量的赋值：<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;变量的声明和定义的过程</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">1</span>]: a=<span class="number">1</span></div><div class="line"> </div><div class="line">In [<span class="number">2</span>]: id(a)</div><div class="line">Out[<span class="number">2</span>]: <span class="number">13933672</span></div><div class="line"> </div><div class="line">In [<span class="number">3</span>]: id(a)</div><div class="line">Out[<span class="number">3</span>]: <span class="number">13933672</span></div><div class="line"> </div><div class="line">In [<span class="number">4</span>]: a=<span class="number">2</span></div><div class="line"> </div><div class="line">In [<span class="number">5</span>]: id(a)</div><div class="line">Out[<span class="number">5</span>]: <span class="number">13933648</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;id（a）表示变量a在内存里的位置，a的变量值发生改变，在内存中的位置也发生改变。</p>
<h2 id="Python-运算符"><a href="#Python-运算符" class="headerlink" title="Python 运算符"></a>Python 运算符</h2><h3 id="1-算数运算符"><a href="#1-算数运算符" class="headerlink" title="1.算数运算符"></a>1.算数运算符</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;+，一个值加上另一个值，也可以是一个字符串加上另一个字符串</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">38</span>]: <span class="number">3</span> + <span class="number">4</span></div><div class="line">Out[<span class="number">38</span>]: <span class="number">7</span></div><div class="line"> </div><div class="line">In [<span class="number">39</span>]: <span class="string">'a'</span> + <span class="string">'b'</span></div><div class="line">Out[<span class="number">39</span>]: <span class="string">'ab'</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;-，一个值减去另一个值</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">40</span>]: <span class="number">5</span> - <span class="number">4</span></div><div class="line">Out[<span class="number">40</span>]: <span class="number">1</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;*，一个值乘以另一个值</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">44</span>]: <span class="number">3</span> * <span class="number">4</span></div><div class="line">Out[<span class="number">44</span>]: <span class="number">12</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;/，一个值除以另一个值</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">45</span>]: <span class="number">4</span> / <span class="number">3</span></div><div class="line">Out[<span class="number">45</span>]: <span class="number">1</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;注意：这里只取整数，如果想要小数点，那么除法运算的两个数值至少一个要是浮点数</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">46</span>]: <span class="number">4.0</span> / <span class="number">3</span></div><div class="line">Out[<span class="number">46</span>]: <span class="number">1.3333333333333333</span></div><div class="line"> </div><div class="line">In [<span class="number">47</span>]: <span class="number">4</span> / <span class="number">3.0</span></div><div class="line">Out[<span class="number">47</span>]: <span class="number">1.3333333333333333</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//，只取整除，数值带上小数点也只取整数</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">48</span>]: <span class="number">4.0</span> // <span class="number">3</span></div><div class="line">Out[<span class="number">48</span>]: <span class="number">1.0</span></div><div class="line"> </div><div class="line">In [<span class="number">49</span>]: <span class="number">4</span> // <span class="number">3.0</span></div><div class="line">Out[<span class="number">49</span>]: <span class="number">1.0</span></div><div class="line"> </div><div class="line">In [<span class="number">50</span>]: <span class="number">4</span> // <span class="number">3</span></div><div class="line">Out[<span class="number">50</span>]: <span class="number">1</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;%，表示取余</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">51</span>]: <span class="number">4</span> % <span class="number">3</span></div><div class="line">Out[<span class="number">51</span>]: <span class="number">1</span></div><div class="line"> </div><div class="line">In [<span class="number">52</span>]: <span class="number">5</span> % <span class="number">3</span></div><div class="line">Out[<span class="number">52</span>]: <span class="number">2</span></div><div class="line"> </div><div class="line">In [<span class="number">53</span>]: <span class="number">6</span> % <span class="number">3</span></div><div class="line">Out[<span class="number">53</span>]: <span class="number">0</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;**，表示乘方</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">54</span>]: <span class="number">2</span> ** <span class="number">3</span></div><div class="line">Out[<span class="number">54</span>]: <span class="number">8</span></div><div class="line"> </div><div class="line">In [<span class="number">55</span>]: <span class="number">2</span> ** <span class="number">10</span></div><div class="line">Out[<span class="number">55</span>]: <span class="number">1024</span></div></pre></td></tr></table></figure>
<h3 id="2-关系（比较）运算符"><a href="#2-关系（比较）运算符" class="headerlink" title="2.关系（比较）运算符"></a>2.关系（比较）运算符</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;，大于</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">56</span>]: <span class="number">2</span> &gt; <span class="number">1</span></div><div class="line">Out[<span class="number">56</span>]: <span class="keyword">True</span></div><div class="line"> </div><div class="line">In [<span class="number">57</span>]: <span class="number">1</span> &gt; <span class="number">2</span></div><div class="line">Out[<span class="number">57</span>]: <span class="keyword">False</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;，小于</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">58</span>]: <span class="number">2</span> &lt; <span class="number">3</span></div><div class="line">Out[<span class="number">58</span>]: <span class="keyword">True</span></div><div class="line"> </div><div class="line">In [<span class="number">59</span>]: <span class="number">3</span> &lt; <span class="number">2</span></div><div class="line">Out[<span class="number">59</span>]: <span class="keyword">False</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;=，大于等于</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">60</span>]: <span class="number">2</span> &gt;= <span class="number">1</span></div><div class="line">Out[<span class="number">60</span>]: <span class="keyword">True</span></div><div class="line"> </div><div class="line">In [<span class="number">61</span>]: <span class="number">2</span> &gt;= <span class="number">2</span></div><div class="line">Out[<span class="number">61</span>]: <span class="keyword">True</span></div><div class="line"> </div><div class="line">In [<span class="number">62</span>]: <span class="number">2</span> &gt;= <span class="number">3</span></div><div class="line">Out[<span class="number">62</span>]: <span class="keyword">False</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;=，小于等于</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">63</span>]: <span class="number">2</span> &lt;=<span class="number">3</span></div><div class="line">Out[<span class="number">63</span>]: <span class="keyword">True</span></div><div class="line"> </div><div class="line">In [<span class="number">64</span>]: <span class="number">3</span> &lt;= <span class="number">3</span></div><div class="line">Out[<span class="number">64</span>]: <span class="keyword">True</span></div><div class="line"> </div><div class="line">In [<span class="number">65</span>]: <span class="number">4</span> &lt;= <span class="number">3</span></div><div class="line">Out[<span class="number">65</span>]: <span class="keyword">False</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;==，恒等于</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">72</span>]: <span class="number">1</span> == <span class="number">1</span></div><div class="line">Out[<span class="number">72</span>]: <span class="keyword">True</span></div><div class="line"> </div><div class="line">In [<span class="number">73</span>]: <span class="number">1</span> == <span class="number">2</span></div><div class="line">Out[<span class="number">73</span>]: <span class="keyword">False</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;!=，不等于</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">74</span>]: <span class="number">1</span> != <span class="number">2</span></div><div class="line">Out[<span class="number">74</span>]: <span class="keyword">True</span></div><div class="line"> </div><div class="line">In [<span class="number">75</span>]: <span class="number">2</span> != <span class="number">2</span></div><div class="line">Out[<span class="number">75</span>]: <span class="keyword">False</span></div></pre></td></tr></table></figure>
<h3 id="3-赋值运算符"><a href="#3-赋值运算符" class="headerlink" title="3.赋值运算符"></a>3.赋值运算符</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;=，表示直接给变量赋值，如果是字符串必须加上引号</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">11</span>]: x = <span class="number">3</span></div><div class="line"> </div><div class="line">In [<span class="number">12</span>]: y = <span class="string">'abc'</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;说明：可以通过 type（）命令查看变量是数字还是字符串</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">15</span>]: type(x)</div><div class="line">Out[<span class="number">15</span>]: int</div><div class="line"> </div><div class="line">In [<span class="number">16</span>]: type(y)</div><div class="line">Out[<span class="number">16</span>]: str</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;+=，表示变量 的值再加上一个值（a=a+b）</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">13</span>]: x += <span class="number">2</span></div><div class="line"> </div><div class="line">In [<span class="number">14</span>]: x</div><div class="line">Out[<span class="number">14</span>]: <span class="number">5</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;-=，表示变量的值再减去一个值（a=a-b）</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">17</span>]: x -= <span class="number">1</span></div><div class="line"> </div><div class="line">In [<span class="number">18</span>]: x</div><div class="line">Out[<span class="number">18</span>]: <span class="number">4</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;*=，表示变量的值再乘以一个值（a=a*b）</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">19</span>]: x *= <span class="number">2</span></div><div class="line"> </div><div class="line">In [<span class="number">20</span>]: x</div><div class="line">Out[<span class="number">20</span>]: <span class="number">8</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;/=，表示变量的值再除以一个值（a=a/b）</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">21</span>]: x /= <span class="number">4</span></div><div class="line"> </div><div class="line">In [<span class="number">22</span>]: x</div><div class="line">Out[<span class="number">22</span>]: <span class="number">2</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;%=，表示取余，变量被一个数整除后，还剩多少值（a=a%b）</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">29</span>]: x=<span class="number">10</span></div><div class="line"> </div><div class="line">In [<span class="number">30</span>]: x %= <span class="number">3</span></div><div class="line"> </div><div class="line">In [<span class="number">31</span>]: x</div><div class="line">Out[<span class="number">31</span>]: <span class="number">1</span></div><div class="line"> </div><div class="line">In [<span class="number">32</span>]: x=<span class="number">9</span></div><div class="line"> </div><div class="line">In [<span class="number">33</span>]: x %= <span class="number">3</span></div><div class="line"> </div><div class="line">In [<span class="number">34</span>]: x</div><div class="line">Out[<span class="number">34</span>]: <span class="number">0</span></div><div class="line"> </div><div class="line">In [<span class="number">35</span>]: x=<span class="number">11</span></div><div class="line"> </div><div class="line">In [<span class="number">36</span>]: x %= <span class="number">3</span></div><div class="line"> </div><div class="line">In [<span class="number">37</span>]: x</div><div class="line">Out[<span class="number">37</span>]: <span class="number">2</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;**=，表示乘方，a的b次方（a=a**b）</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">66</span>]: x = <span class="number">2</span></div><div class="line"> </div><div class="line">In [<span class="number">67</span>]: x **= <span class="number">3</span></div><div class="line"> </div><div class="line">In [<span class="number">68</span>]: x</div><div class="line">Out[<span class="number">68</span>]: <span class="number">8</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//=，表示整除，（a=a//b）</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">68</span>]: x</div><div class="line">Out[<span class="number">68</span>]: <span class="number">8</span></div><div class="line"> </div><div class="line">In [<span class="number">69</span>]: x //= <span class="number">3</span></div><div class="line"> </div><div class="line">In [<span class="number">70</span>]: x</div><div class="line">Out[<span class="number">70</span>]: <span class="number">2</span></div></pre></td></tr></table></figure>
<h3 id="4-逻辑运算符"><a href="#4-逻辑运算符" class="headerlink" title="4.逻辑运算符"></a>4.逻辑运算符</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;and，逻辑与：true and false。表示一个成立and另一个也成立，返回值是 true</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">77</span>]: <span class="number">3</span> &gt; <span class="number">2</span> <span class="keyword">and</span> <span class="number">1</span> &lt; <span class="number">2</span></div><div class="line">Out[<span class="number">77</span>]: <span class="keyword">True</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果其中一个不成立，返回值是 false</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">78</span>]: <span class="number">1</span> == <span class="number">2</span> <span class="keyword">and</span> <span class="number">2</span> &gt; <span class="number">1</span></div><div class="line">Out[<span class="number">78</span>]: <span class="keyword">False</span></div><div class="line"> </div><div class="line">In [<span class="number">79</span>]: <span class="number">1</span> &lt; <span class="number">2</span> <span class="keyword">and</span> <span class="number">1</span> != <span class="number">1</span></div><div class="line">Out[<span class="number">79</span>]: <span class="keyword">False</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;or，逻辑或：false or true，表示只要有一个成立那么返回就是true</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">80</span>]: <span class="number">1</span> &lt; <span class="number">2</span> <span class="keyword">or</span> <span class="number">1</span> != <span class="number">1</span></div><div class="line">Out[<span class="number">80</span>]: <span class="keyword">True</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;not，逻辑非：not true，表示取反</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">81</span>]: <span class="keyword">not</span> <span class="number">1</span> &lt; <span class="number">2</span></div><div class="line">Out[<span class="number">81</span>]: <span class="keyword">False</span></div><div class="line"> </div><div class="line">In [<span class="number">82</span>]: <span class="keyword">not</span> <span class="number">1</span> != <span class="number">1</span></div><div class="line">Out[<span class="number">82</span>]: <span class="keyword">True</span></div></pre></td></tr></table></figure>
<h3 id="5-身份运算符"><a href="#5-身份运算符" class="headerlink" title="5.身份运算符"></a>5.身份运算符</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;身份运算符用来判断两个变量的引用对象是否指向统一个内存的对象，即 id(varibale1)?=id(variable2)。</p>
<ul>
<li>is：判断两个标识符是不是引用自一个对象</li>
<li>is not：判断两个标识符是不是引用不同对象</li>
</ul>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">88</span>]: a = [<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>]</div><div class="line"> </div><div class="line">In [<span class="number">89</span>]: b = [<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>]</div><div class="line"> </div><div class="line">In [<span class="number">90</span>]: <span class="keyword">print</span> ( a == b )</div><div class="line"><span class="keyword">True</span></div><div class="line"> </div><div class="line">In [<span class="number">91</span>]: <span class="keyword">print</span> ( a <span class="keyword">is</span> b )</div><div class="line"><span class="keyword">False</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;因为变量 a 和变量 b 的 value 是一样的， == 运算符比较的变量的 value ，所以返回true。is 是判断两个变量是否引用同一个对象，也就是比较的是 id ，所以返回 false。</p>
<h3 id="6-成员关系运算符"><a href="#6-成员关系运算符" class="headerlink" title="6.成员关系运算符"></a>6.成员关系运算符</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;成员运算符能够判断一个指定对象是否是作为一个容器中的元素，由此来判断两个对象间的关系。<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;容器：包含了其他对象的引用的数据类型。</p>
<ul>
<li>in：当一个对象存在一个容器中时为 true</li>
<li>not in：当一个对象不在一个容器中时为 true</li>
</ul>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">In [<span class="number">93</span>]: a = <span class="number">1</span></div><div class="line"> </div><div class="line">In [<span class="number">94</span>]: b = <span class="number">2</span></div><div class="line"> </div><div class="line">In [<span class="number">95</span>]: c = [<span class="number">1</span>,<span class="number">3</span>,<span class="number">4</span>]</div><div class="line"> </div><div class="line">In [<span class="number">96</span>]: a <span class="keyword">in</span> c</div><div class="line">Out[<span class="number">98</span>]: <span class="keyword">True</span></div><div class="line"> </div><div class="line">In [<span class="number">97</span>]: b <span class="keyword">in</span> c</div><div class="line">Out[<span class="number">99</span>]: <span class="keyword">False</span></div></pre></td></tr></table></figure>
<h3 id="7-位运算符"><a href="#7-位运算符" class="headerlink" title="7.位运算符"></a>7.位运算符</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在 Python 中 |、&amp;、^、~等运算符的意思不在于处理逻辑关系，而是二进制数据的为运算，数字以二进制形式的补码存储和计算，以原码结果来显示。若数字为正值，它的补码就是原码本身、若为负值，则它的补码为源码减1再按位取反。两个数字的计算本质是两个二进制补码的计算。</p>
<ul>
<li>|：按位或运算符，只要对应的二个二进位有一个为1时，结果位就为1.</li>
<li>&amp;：按位与运算符，参与运算的两个值，如果两个相应的位都为1，则该位为的结果为1，否则为0</li>
<li>^：按位异或运算符，当两对应的二进位相异时，结果为1</li>
<li>~：按位取反运算符，对数据的每个二进制位取反，即把1变为0，把0变为1</li>
</ul>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">a = <span class="number">0011</span> <span class="number">1100</span></div><div class="line"> </div><div class="line">b = <span class="number">0000</span> <span class="number">1101</span></div><div class="line"> </div><div class="line">-----------------</div><div class="line"> </div><div class="line">a&amp;b = <span class="number">0000</span> <span class="number">1100</span></div><div class="line"> </div><div class="line">a|b = <span class="number">0011</span> <span class="number">1101</span></div><div class="line"> </div><div class="line">a^b = <span class="number">0011</span> <span class="number">0001</span></div><div class="line"> </div><div class="line">~a = <span class="number">1100</span> <span class="number">0011</span></div></pre></td></tr></table></figure>
<h3 id="8-位移运算符"><a href="#8-位移运算符" class="headerlink" title="8.位移运算符"></a>8.位移运算符</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;位移运算符是非常有效率的计算方法之一，在对数学运算和对程序执行效率要求高的程序中推荐使用。</p>
<ul>
<li>&lt;&lt;：左移动运算符，运算数的各二进位全部左移若干位，由 “&lt;&lt;” 右边的数值指定移动的位数，高位丢弃，低位补0</li>
<li><blockquote>
<blockquote>
<p>：右移动运算符，把 “&gt;&gt;” 左边的运算数的各二进位全部右移若干位， “&gt;&gt;” 右边的数指定移动的位数</p>
</blockquote>
</blockquote>
</li>
</ul>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">a = <span class="number">0011</span> <span class="number">1100</span></div><div class="line"> </div><div class="line">a &lt;&lt; <span class="number">2</span> <span class="number">1111</span> <span class="number">0000</span> <span class="comment">#结果为240</span></div><div class="line"> </div><div class="line">a &gt;&gt; <span class="number">2</span> <span class="number">0000</span> <span class="number">1111</span> <span class="comment">#结果为15</span></div></pre></td></tr></table></figure>
<h2 id="Python运算符优先级"><a href="#Python运算符优先级" class="headerlink" title="Python运算符优先级"></a>Python运算符优先级</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;下标列出了从最高到最低优先级的所有运算符：</p>
<table>
<thead>
<tr>
<th>运算符</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>**</td>
<td>指数 (最高优先级)</td>
</tr>
<tr>
<td>~ + -</td>
<td>按位翻转, 一元加号和减号 (最后两个的方法名为 +@ 和 -@)</td>
</tr>
<tr>
<td>* / % //</td>
<td>乘，除，取模和取整除</td>
</tr>
<tr>
<td>+ -</td>
<td>加法减法</td>
</tr>
<tr>
<td>&gt;&gt; &lt;&lt;</td>
<td>右移，左移运算符</td>
</tr>
<tr>
<td>&amp;</td>
<td>位 ‘AND’</td>
</tr>
<tr>
<td>^ \</td>
<td></td>
<td>位运算符</td>
</tr>
<tr>
<td>&lt;= &lt; &gt; &gt;=</td>
<td>比较运算符</td>
</tr>
<tr>
<td>&lt;&gt; == !=</td>
<td>等于运算符</td>
</tr>
<tr>
<td>= %= /= //= -= += <em>= *</em>=</td>
<td>赋值运算符</td>
</tr>
<tr>
<td>is is not</td>
<td>身份运算符</td>
</tr>
<tr>
<td>in not in</td>
<td>成员运算符</td>
</tr>
<tr>
<td>not or and</td>
<td>逻辑运算符</td>
</tr>
</tbody>
</table>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;以下实例演示了python所有运算符优先级的操作：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#!/usr/bin/python</span></div><div class="line"><span class="comment"># -*- coding: UTF-8 -*-</span></div><div class="line">  </div><div class="line">a = <span class="number">20</span></div><div class="line">b = <span class="number">10</span></div><div class="line">c = <span class="number">15</span></div><div class="line">d = <span class="number">5</span></div><div class="line">e = <span class="number">0</span></div><div class="line">  </div><div class="line">e = (a + b) * c / d <span class="comment">#( 30 * 15 ) / 5</span></div><div class="line"><span class="keyword">print</span> <span class="string">"(a + b) * c / d 运算结果为："</span>, e</div><div class="line">  </div><div class="line">e = ((a + b) * c) / d <span class="comment"># (30 * 15 ) / 5</span></div><div class="line"><span class="keyword">print</span> <span class="string">"((a + b) * c) / d 运算结果为："</span>, e</div><div class="line">  </div><div class="line">e = (a + b) * (c / d); <span class="comment"># (30) * (15/5)</span></div><div class="line"><span class="keyword">print</span> <span class="string">"(a + b) * (c / d) 运算结果为："</span>, e</div><div class="line">  </div><div class="line">e = a + (b * c) / d; <span class="comment"># 20 + (150/5)</span></div><div class="line"><span class="keyword">print</span> <span class="string">"a + (b * c) / d 运算结果为："</span>, e</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;输出结果：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">(a + b) * c / d 运算结果为： <span class="number">90</span></div><div class="line">((a + b) * c) / d 运算结果为： <span class="number">90</span></div><div class="line">(a + b) * (c / d) 运算结果为： <span class="number">90</span></div><div class="line">a + (b * c) / d 运算结果为： <span class="number">50</span></div></pre></td></tr></table></figure>
      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Python/" rel="tag"># Python</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/08/10/Python/1. Python 基础篇/1. Python 基础语法/1.8 字典/10. Python 字典（Dictionary）/" rel="prev" title="Python 字典（Dictionary）">
                Python 字典（Dictionary） <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/0.png"
               alt="失落的乐章" />
          <p class="site-author-name" itemprop="name">失落的乐章</p>
           
              <p class="site-description motion-element" itemprop="description">失落的乐章的Blog</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">627</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hcldirgit" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Python-的变量"><span class="nav-number">1.</span> <span class="nav-text">Python 的变量</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#变量的命名："><span class="nav-number">1.1.</span> <span class="nav-text">变量的命名：</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Python对象的三要素：id、type、value"><span class="nav-number">1.1.1.</span> <span class="nav-text">Python对象的三要素：id、type、value</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Python-运算符"><span class="nav-number">1.2.</span> <span class="nav-text">Python 运算符</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-算数运算符"><span class="nav-number">1.2.1.</span> <span class="nav-text">1.算数运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-关系（比较）运算符"><span class="nav-number">1.2.2.</span> <span class="nav-text">2.关系（比较）运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-赋值运算符"><span class="nav-number">1.2.3.</span> <span class="nav-text">3.赋值运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-逻辑运算符"><span class="nav-number">1.2.4.</span> <span class="nav-text">4.逻辑运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-身份运算符"><span class="nav-number">1.2.5.</span> <span class="nav-text">5.身份运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-成员关系运算符"><span class="nav-number">1.2.6.</span> <span class="nav-text">6.成员关系运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-位运算符"><span class="nav-number">1.2.7.</span> <span class="nav-text">7.位运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#8-位移运算符"><span class="nav-number">1.2.8.</span> <span class="nav-text">8.位移运算符</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Python运算符优先级"><span class="nav-number">1.3.</span> <span class="nav-text">Python运算符优先级</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">失落的乐章</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
